package cn.seaboot.excel;

import cn.seaboot.excel.html.SheetReader;
import cn.seaboot.excel.html.StyleReader;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.dom4j.DocumentException;

import java.io.IOException;
import java.io.StringWriter;

/**
 * @author Mr.css
 * @version 2025-06-30 17:20
 */
public class ExcelToHtml {

    public static void main(String[] args) throws IOException, DocumentException {
        String file = "C:\\Users\\ASUS\\Desktop\\a.xlsx";

        StringWriter writer = new StringWriter();
        try (Workbook workbook = new XSSFWorkbook(file)) {
            Sheet sheet = workbook.getSheetAt(0);

            // 读取数据
            SheetReader sheetReader = new SheetReader(writer);
            sheetReader.setWidthReferenceRow(2);
            sheetReader.read(sheet);

            // 读取样式
            StyleReader styleReader = new StyleReader(writer);
            styleReader.read(workbook);
        }

        System.out.println(writer.toString());
    }
}
